# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=sddm
pkgver=0.19.0
pkgrel=3
pkgdesc="Simple Desktop Display Manager"
url="https://github.com/sddm/sddm/"
# armhf blocked by qt5-qtdeclarative
# s390x and riscv64 blocked by polkit -> upower
# riscv64 disabled due to missing rust in recursive dependency
arch="all !armhf !s390x !riscv64"
license="GPL-2.0-only"
depends="
	dbus-x11
	elogind
	linux-pam>=1.4
	upower
	xorg-server
	"
makedepends="
	elogind-dev
	extra-cmake-modules
	libxcb-dev
	linux-pam-dev
	py3-docutils
	qt5-qtbase-dev
	qt5-qtdeclarative-dev
	qt5-qttools-dev
	upower-dev
	utmps-dev
	"
subpackages="$pkgname-doc $pkgname-lang $pkgname-openrc"
install="sddm.pre-install"
langdir="/usr/share/sddm/translations"
pkgusers="sddm"
pkggroups="sddm"
source="https://github.com/sddm/sddm/archive/v$pkgver/sddm-v$pkgver.tar.gz
	0001-pam-path-fix.patch
	0002-sddm-fix-build.patch
	sddm.initd
	sddm.confd
	"

# secfixes:
#   0.19.0-r0:
#     - CVE-2020-28049

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_MAN_PAGES=ON \
		-DENABLE_JOURNALD=OFF \
		-DNO_SYSTEMD=ON \
		-DUSE_ELOGIND=ON \
		-DUID_MIN=500 \
		-DUID_MAX=65000 \
		-DDBUS_CONFIG_DIR=/usr/share/dbus-1/system.d
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	install -Dm755 "$srcdir"/sddm.initd "$pkgdir"/etc/init.d/sddm
	install -Dm644 "$srcdir"/sddm.confd "$pkgdir"/etc/conf.d/sddm
}

sha512sums="
f4de3d2da844caa8c5639ec39d4f41305d4fcad9ca29fe381c2c1d4b1bba0e54d47b8644e2c72d41fe9d11f3792959c3dd14f76d9ebc0de2b8ab7675c3e9acf7  sddm-v0.19.0.tar.gz
f0b4eb7ef0581701157f9decc637629156f36f6711b9a4bae517f94d7a1df614c81bbd891c918f07ac50e2a3d1519c43ccb9eefd80282c95dd79eca0e8d90904  0001-pam-path-fix.patch
d2d4a6df0a329f37776e3efe3359e730c20ee5da3180b23f9b728afe924d9146f50f3377b9bfa2d7439e09640c33ecefda75707fda74e91812f97ec6358343ab  0002-sddm-fix-build.patch
4876bf46790dd507f0df803987ad81d7ff2a00c22a8aabec88dd0e3a23aeda92aac59f08ef56ed1bf2b5cb9443077e77b31c9f453bafab2fd6f533be242fcbd4  sddm.initd
b841282b96110ec59a7aa539db0737327b09549d55c78dc4b2c3b28b4a6ad1facf015b3175cb6d3a38f13e47aa6314ef3dc1514a4e60dd653a97409ec54ba706  sddm.confd
"
